<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                        <li>站点:</li>
                        <div class="col-sm-8">
                            <select id="deptId" name="deptId" class="form-control m-b">
                                <option value="">所有</option>
                                <option th:each="zhDept:${zhDepts}" th:value="${zhDept.deptId}"
                                        th:text="${zhDept.name}"></option>
                            </select>
                        </div>
                        </li>
                        <div style="clear: both"></div>

                        <li>
                            支付方式：<select name="payType">
                            <option value="">所有</option>
                            <option value="0">支付宝</option>
                        </select>
                        </li>
                        <li>
                            支付状态：<select name="payStatus">
                            <option value="">所有</option>
                            <option value="0">未支付</option>
                            <option value="1">已支付</option>
                            <option value="-1">金额异常</option>
                        </select>
                        </li>

                        <li>
                            订单号：<input type="text" name="outTradeNo"/>
                        </li>

                        <li>
                            支付方流水号：<input type="text" name="tradeNo"/>
                        </li>

                        <li>
                            购买者用户名：<input type="text" name="buyerUsername"/>
                        </li>

                        <li>
                            出售者用户名：<input type="text" name="salerUsername"/>
                        </li>

                        <li>
                            购买者游戏角色名：<input type="text" name="buyerGameRoleName"/>
                        </li>

                        <li>
                            支付时间：<input type="text" name="payTime"/>
                        </li>

                        <li>
                            发货时间：<input type="text" name="deliveryTime"/>
                        </li>

                        <li>
                            商品名称：<input type="text" name="goodName"/>
                        </li>

                        <li>
                            实际付款金额：<input type="text" name="orderRealPayAmount"/>
                        </li>


                        <li>
                            购买者游戏角色区服名：<input type="text" name="buyerGameRoleAreaName"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
            <a class="btn btn-primary btn-edit disabled" onclick="setDelivery()"
               shiro:hasPermission="system:zhOrder:setDelivery">
                <i class="fa fa-edit"></i> 设置已发货
            </a>
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:zhOrder:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()"
               shiro:hasPermission="system:zhOrder:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:zhOrder:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:zhOrder:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:zhOrder:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:zhOrder:remove')}]];
    var prefix = ctx + "system/zhOrder";
    function setDelivery(id){
        var data = {};
        //
        if ($.common.isNotEmpty(id)) {

        } else {
            var id = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId);
            if (id.length == 0) {
                $.modal.alertWarning("请选择一条记录");
                return;
            }else{
                if(id.length>1){
                    $.modal.alertWarning("最多选择一条记录");
                    return;
                }
            }
            var url  = "/system/zhOrder/delivery/"+id;
            var config = {
                url: url,
                type: "put",
                dataType: "json",
                data: data,
                success: function(result) {
                    if(result.code==0){
                        $.modal.msg("成功");
                        $.table.refresh();

                    }else{
                        $.modal.alertError(result.msg);
                    }
                }
            };
            $.ajax(config);
        }


    }

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "订单",
            search: false,
            showExport: true,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'deptName',
                    title: '站点名称',
                    sortable: true,
                    align: "left"

                },
                {
                    field: 'outTradeNo',
                    title: '订单号',
                    sortable: true
                },
                {
                    field: 'tradeNo',
                    title: '支付方流水号',
                    sortable: true
                },

                {
                    field: 'buyerUsername',
                    title: '购买者用户名',
                    sortable: true
                },
                {
                    field: 'salerUsername',
                    title: '出售者用户名',
                    sortable: true
                },

                {
                    field: 'buyerGameRoleName',
                    title: '购买者游戏角色名',
                    sortable: true
                },
                {
                    field: 'buyerGameRoleAreaName',
                    title: '购买者游戏角色区服名',
                    sortable: true
                },
                {
                    field: 'payStatus',
                    title: '支付状态',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value == 0) {
                            return "未支付";
                        } else if (value == 1) {
                            return "已支付";
                        } else if (value == -1) {
                            return "金额异常";
                        }
                    }
                },
                {
                    field: 'payTime',
                    title: '支付时间',
                    sortable: true
                },
                {
                    field: 'deliveryTime',
                    title: '发货时间',
                    sortable: true
                },
                {
                    field: 'goodName',
                    title: '商品名称',
                    sortable: true
                },
                {
                    field: 'goodCount',
                    title: '商品数量',
                    sortable: true
                },
                {
                    field: 'goodSinglePrice',
                    title: '单个商品价格',
                    sortable: true
                },
                {
                    field: 'goodAmountTotal',
                    title: '订单商品总价',
                    sortable: true
                },
                {
                    field: 'orderRealPayAmount',
                    title: '实际付款金额',
                    sortable: true
                },
                {
                    field: 'payType',
                    title: '支付方式',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (value == 0) {
                            return "未支付";
                        } else if (value == 1) {
                            return "支付宝";
                        }
                    }
                },

                {
                    field: 'deptId',
                    title: '站点id',
                    sortable: true
                },
                {
                    field: 'gmtCreate',
                    title: '创建时间',
                    sortable: true
                },
                {
                    field: 'gmtModified',
                    title: '更新时间',
                    sortable: true
                },
                {
                    field: 'remark',
                    title: '备注',
                    sortable: true
                },


                // {
                //     title: '操作',
                //     align: 'center',
                //     formatter: function(value, row, index) {
                //     	var actions = [];
                //     	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                //         actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                // 		return actions.join('');
                //     }
                // }
            ]
        };
        $.table.init(options);


    });
</script>
</body>
</html>